home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------------------*\
- Auto login to uxa through mosberg using Term 3.4
- by Nicolas Dade, December 1993, $VER: 1.02
-
- throughout I refer to the terminal server as being mosberg, but it
- can be any of the many that are in use---term, ruger, beretta,...
-
- The script takes an optional parameter, the name of a message
- port to which to send a message once the login is complete. This
- is for use by scripts that need to know then the login is over
- and they can proceed.
-
- for example, specifying the Startup/Login macro in term to be
- \a rexx:Login-Uxa.term autodownload.login.finished
- will make the login script send a message to a port called
- "autodownload.login.finished" when it is finished.
-
- \*----------------------------------------------------------------------*/
-
- PARSE ARG portname .
-
- RESETSCREEN
-
- /* get mosberg to wakeup by sending CR until it prompts for our username */
- TIMEOUT 'SEC 2'
- woken='no'
- DO i = 1 TO 10 WHILE woken='no'
- SEND '\r'
- WAIT '"username:"'
- IF rc=0 THEN woken='yes'
- END
- IF woken~='yes' THEN DO
- showerror("Couldn't get terminal server to respond.")
- finish(10)
- END
-
- /* login to mosberg using our ph alias and password */
- SEND 'nicolas-dade\r'
- TIMEOUT 'SEC 10'
- IF waitrc('password:',"Terminal server never asked for 'Password' after asking for 'Username'") THEN finish(10)
- SEND 'NOECHO myphpassword\r'
- /* put mosberg in no-translation terminal mode */
- IF waitrc('>',"Terminal server never gave a prompt after login") THEN finish(10)
- SEND 'term download\r'
- /* connect from mosberg to uxa */
- IF waitrc('>',"Terminal server never gave a prompt after setting term to download") THEN finish(10)
- SEND 'uxa\r'
-
- /* login to uxa using uxa login and password */
- IF waitrc('login:',"uxa never asked for 'login', or uxa never responded") THEN finish(10)
- SEND 'n-dade\r'
- IF waitrc('password:',"uxa never asked for 'password'") THEN finish(10)
- SEND 'NOECHO myuxapassword\r'
- /* keep sending CR until the first shell prompt appears */
- atshell='no'
- timeout sec 2
- DO i = 1 TO 10 WHILE atshell='no'
- SEND '\r'
- WAIT '"uxa 1>"'
- IF rc=0 THEN atshell='yes'
- END
- IF atshell~='yes' THEN DO
- showerror("Couldn't get uxa to give first shell prompt.")
- finish(10)
- END
-
- /* exit, things went ok */
- ACTIVATE
- finish(0)
-
- /*--------------------------------------*/
-
- waitrc: /* (waitstring, errorstring) */
- PARSE ARG waitstring,errorstring
- TIMEOUT 'SEC 30'
- WAIT '"'waitstring'"'
- IF rc=0 THEN DO
- RETURN 0
- END
- ELSE DO
- showerror(errorstring)
- return 1
- END
-
- showerror: /* (errorstring) */
- PARSE ARG errorstring
- IF portname='' THEN
- REQUESTNOTIFY 'TITLE "AutoLogin Aborting" PROMPT "'errorstring'"'
- ELSE
- say 'AutoLogin Aborting: 'errorstring
- RETURN 0
-
- finish: /* (return code) */
- PARSE ARG returncode .
- IF portname~='' THEN
- IF show('ports',portname) THEN
- INTERPRET "ADDRESS '"portname"' returncode" /* send message to waiting controling arexx script */
- EXIT returncode
-